package com.autonavi.yunda.yunji.common.web;


import com.google.common.collect.Lists;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class HttpFilterConfig {

    @Bean
    public FilterRegistrationBean tracedHttpSpringFilter() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        TracedHttpSpringFilterConfig tracedHttpSpringFilter = new TracedHttpSpringFilterConfig();
        tracedHttpSpringFilter.addExcludes(Lists.newArrayList("/checkpreload.htm", "/actuator/health", "/health", "/tmd_status", "/status.taobao", "/favicon.ico"));
        registration.setFilter(tracedHttpSpringFilter);
        registration.addInitParameter("responseLogging", "true");
        registration.addInitParameter("requestLogging", "true");
        registration.addInitParameter("gsidField", "gsid");
        registration.addInitParameter("bizidField", "key");
        registration.addInitParameter("ignoreHeader", "host;connection;upgrade-insecure-requests");
        registration.addInitParameter("ignoreCookie", "JSESSIONID;_umdata");
        registration.addInitParameter("ignoreParam", "wkt;other");
        registration.addInitParameter("requestParse", "true");
        registration.setName("tracedHttpSpringFilter");
        registration.addUrlPatterns("/*");
        registration.setOrder(1);
        return registration;
    }

}
